package Socket;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Socket1 {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",8888);
        //这里使用的IP地址是自己电脑的
        OutputStream os = socket.getOutputStream();
        os.write("你好服务器".getBytes());
        //给服务器发送数据
        /*现在还没有服务器，所以这一段代码运行不了*/
        InputStream is = socket.getInputStream();
        byte[] bytes = new byte[1024];
        int len = is.read(bytes);
        System.out.println(new String(bytes,0,len));
        socket.close();
    }
}
